package com.socket.socketMoreTest;

import com.socket.socketObjTest.User;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.Socket;

/**
 * ServerThread--bdqnPractice
 *
 * @author: Jovi
 * @createTime: 2017-09-07 15:36
 **/
public class ServerThread extends Thread {

    Socket socket = null;

    public ServerThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            InputStream is = socket.getInputStream();
            ObjectInputStream ois = new ObjectInputStream(is);

            try {
                User user = (User)ois.readObject();
                System.out.println("用户信息："+user);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }

            ois.close();
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
